
%Declare the symbolic variables (syms)
syms QVal zVal lgVal lbVal deltaVal

%f=Qstar*exp(QVal)-exp(zVal)*(yg*lgVal+yb*lbVal)/(1-deltaVal);
f=Qstar*exp(QVal)-exp(zVal)*(yg*lgVal+yb*lbVal); %Changed by Leonardo 1/20/2021 

%Take symbolic derivatives
dd1 = diff(f,QVal);
dd2 = diff(f,zVal);
dd3 = diff(f,lgVal);
dd4 = diff(f,lbVal);
%dd5 = diff(f,deltaVal);%Changed by Leonardo 1/20/2021 

%Evaluates symbolic derivatives

QVal=0;  %loglin
zVal=0;  %loglin
lgVal=lg0;  %linearize
lbVal=lb0;  %linearize
% deltaVal=delta;  %linearize %Changed by Leonardo 1/20/2021 


D1=subs(dd1);
D2=subs(dd2);
D3=subs(dd3);
D4=subs(dd4);
% D5=subs(dd5);%Changed by Leonardo 1/20/2021 

% Transform symbolic into numbers (with double precision)
d1=double(D1);
d2=double(D2);
d3=double(D3);
d4=double(D4);
% d5=double(D5);%Changed by Leonardo 1/20/2021 

ACont(11,QLog)        = d1;
ACont(11,shkaLog)     = d2;
ACont(11,lgLog)       = d3;
ACont(11,lbLog)       = d4;
% ACont(11,shkdeltaLog)   = d5;%Changed by Leonardo 1/20/2021 
